home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / sst115j.lzh / EDEMO.C < prev    next >
C/C++ Source or Header  |  1992-08-01  |  2KB  |  76 lines

  1. /* ------------------------------------------------------------------------ */
  2. /*                                 tdemo.c                                  */
  3. /* ------------------------------------------------------------------------ */
  4.  
  5. #include <dos.h>
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <mem.h>
  9. #include <stdlib.h>
  10. #include <conio.h>
  11.  
  12. #include "sstkey.h"
  13. #include "sstwin.h"
  14. #include "sstedt.h"
  15.  
  16. void ShowEditor            (void);
  17. void main                  (void);
  18.  
  19.  
  20.  
  21. /* ------------------------------------------------------------------------ */
  22. /*                             demo on editor                               */
  23. /* ------------------------------------------------------------------------ */
  24. void ShowEditor(void)
  25.  
  26. #define LWID      (int)80
  27. #define WHT       (int)20
  28. #define PADHT          20
  29.  
  30. {
  31.   char buf [PADHT] [LWID];
  32.   char notefile [] = "test.txt";
  33.   WINDOW *wnd;
  34.   FILE *fp, *fopen();
  35.   int i, ctr = 0;
  36.  
  37.     setmem(buf, sizeof buf, 0x00);
  38.     if ((fp = fopen(notefile, "rt")) != NULL)    {
  39.         while (fread(buf [ctr], LWID, 1, fp))
  40.             ctr++;
  41.         fclose(fp);
  42.     }
  43.     wnd = Westablish
  44.         ((80-(LWID+2))/2, (25-(WHT+2))/2, WHT+2, LWID+2);
  45.     Wsetborder(wnd, BRD_SINGLE);
  46.     Wsettitle(wnd, " VB (very basic) Eopen ",JUST_C);
  47.     Wsetcolour(wnd, WIN_FACE, CYAN, BLUE, DIM);
  48.     Wsetcolour(wnd, WIN_TITLE, CYAN, YELLOW, DIM);
  49.     Wsetcolour(wnd, WIN_ACCENT, LIGHTGRAY, CYAN, DIM);
  50.     Wsetcolour(wnd, WIN_BORDER, CYAN, BLACK, DIM);
  51.     Wshow(wnd);
  52.     Eopen(wnd, (char*) buf, LWID * PADHT);
  53.     Wdelete(wnd);
  54.     ctr = PADHT;
  55.     while (--ctr)    {
  56.         for (i = 0; i < LWID; i++)
  57.             if (buf [ctr] [i] != ' ')
  58.                 break;
  59.         if (i < LWID)
  60.             break;
  61.     }
  62.     fp = fopen(notefile, "w");
  63.     for (i = 0; i < ctr+1; i++)
  64.         fwrite(buf[i], LWID, 1, fp);
  65.     fclose(fp);
  66. }
  67.  
  68.  
  69. /* ------------------------------------------------------------------------ */
  70. void main(void)
  71.  
  72. {
  73.  ShowEditor();
  74. }
  75.  
  76.